package com.hongkzh.www.look.enterprise.userinfo.presenter;


import android.util.Log;

import com.hongkzh.www.look.enterprise.userinfo.model.bean.MediaProductBean;
import com.hongkzh.www.other.okhttp.CallBackUtil;
import com.hongkzh.www.other.okhttp.OkhttpUtil;
import com.hongkzh.www.look.enterprise.userinfo.view.iview.MediaProductIView;
import com.hongkzh.www.presenter.BasePresenter;

import okhttp3.Call;

import static com.hongkzh.www.other.api.Api.GETALLProductBYUSERID;


/**
 * Created by as on 2018/3/31.
 * 媒体简介 产品
 */

public class MediaProductPresenter extends BasePresenter<MediaProductIView> {

    private boolean isLastPage = false;

    @Override
    public void attachView(MediaProductIView iView) {
        super.attachView(iView);
    }


    public void getMediaProduct(String uid, String pageNumber, String sortId, String sortValue) {
        String url = GETALLProductBYUSERID(uid, pageNumber, sortId, sortValue);
        Log.i("qa请求的产品的url===", url);
        OkhttpUtil.okHttpPost(url, new CallBackUtil<MediaProductBean>() {
            @Override
            public void onFailure(Call call, Exception e) {

            }

            @Override
            public void onResponse(MediaProductBean response) {
                isLastPage = response.getData().isLastPage();
                if (isLastPage)
                    getIView().onLastPage(isLastPage);
                getIView().onShowMediaProductList(response);
            }
        });

    }

    @Override
    public MediaProductIView getIView() {
        return super.getIView();
    }

    @Override
    public void detachView() {
        super.detachView();
    }
}